<template>
  <!-- 发送留言 -->
  <div>
    <!-- 文本区域 -->
    <div class="content">
      <el-form :ref="form" :model="form" :rules="rules">
        <el-form-item label="你的留言" prop="resMessage_content">
          <el-input
            type="textarea"
            :rows="10"
            placeholder="请输入内容"
            v-model="form.resMessage_content"
          >
          </el-input>
        </el-form-item>
      </el-form>
    </div>
    <el-button @click="send()">发送</el-button>
  </div>
</template>
<script>
export default {
  data () {
    return {
      // topic: "",
      // teacher: "",
      rules: {
        resMessage_content: {
          required: true,
          message: "小哥哥，必填的哟",
          trigger: "blur",
        },
      },
      form: {
        resMessage_content: "",
      },
    };
  },
  methods: {
    // getinfo() {
    //   this.$http.get("http://127.0.0.1:8080/my/getTopic").then((res) => {
    //     // console.log(res);
    //     this.topic = res.data.data[1][0].topic_name;
    //     this.teacher = res.data.data[0][0].teacher_name;
    //   });
    // },

    async send () {
      const n = window.location.hash.substring(27);
      console.log(n);
      const ret = await this.$http.post(
        "http://127.0.0.1:8080/teacher/send?student_num=" + n,
        this.$qs.stringify(this.form)
      );
      this.$message.success("发送成功");
      this.form.resMessage_content = "";
      // console.log(ret);
    },
  },
};
</script>
<style lang="less" scoped>
.content {
  margin: 20px 0;
}
button {
  position: absolute;
  right: 50px;
}
</style>
